package com.cropdoctor.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cropdoctor.model.dto.SysRoleDto;
import com.cropdoctor.model.po.SysRolePo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * Description: 【 用户角色表 数据库操作Mapper 】
 */
@Mapper
public interface SysRoleMapper extends BaseMapper<SysRolePo> {

    // ==================== QUERY ====================


    /**
     * 描述: 【 通过ID查询单条数据 】
     */
    @Select("select t.* from sys_role t where t.id = #{id}")
    SysRoleDto queryOneById(@Param("id") Long id);

    @Select("select r.* from sys_role r LEFT JOIN sys_user_role_relation ur on ur.user_id=r.id where ur.user_id = #{userId}")
    List<SysRolePo> selectByUser(Integer userId);

    // ==================== ADD、MODIFY、REMOVE ===================


    // ==================== OTHERS ====================

}
